<template>
<div>
    <el-table
            :header-cell-style="{background:'#eef1f6',color:'#606266'}"
            @select-all="checkSelect"
            @select="checkSelect"
            ref="multipleTable"
            :data="getPreferentialData"
            stripe
            tooltip-effect="dark"
            style="width: 100%"
            >
                <el-table-column
                type="selection"
                width="55">
                </el-table-column>
                <el-table-column
                align='center'
                prop="event_title"
                label="活动内容"
                min-width="120">
                </el-table-column>
                <el-table-column
                align='center'
                prop="activity_time_start"
                label="开始时间"
                width="120">
                </el-table-column>
                <el-table-column
                align='center'
                prop="activity_time_end"
                label="结束时间">
                </el-table-column>
                <el-table-column
                align='center'
                prop="active_status"
                label="活动状态"
                >
                </el-table-column>
                <el-table-column
                align='center'
                prop="number_of_initial_entries"
                label="已报名/发行量"
                >
                </el-table-column>
                <el-table-column
                scope=scope
                align='center'
                prop=""
                label="操作">
                <template slot-scope="scope">
                    <el-button type="primary" @click="openAddbulk(scope.row)">编辑</el-button>
                </template>
            </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page.sync="nowPage"
      :page-sizes="[5, 10, 30, 50]"
      :page-size="perPageNum"
      layout="sizes, prev, pager, next"
      :total = getTotalSize>
    </el-pagination>
</div>
    
      
    
</template>

<script>
export default {
    name:'',
    data() {
        return {
            nowPage:1,
            perPageNum:5,
            total1:1,
        }
    },
    computed: {
        getPreferentialData(){
            return this.$store.state.PreferentialData.tableData;
        },
        getTotalSize(){
            return this.$store.state.PreferentialData.totalSize;
        }
    },
    methods: {
        checkSelect(val){
            let checkData=[];
            console.log(val);
            for(let i=0;i<val.length;i++){
                if(val[i].active_status==='待审核'){
                    checkData.push(val[i])
                }
            }
            this.$store.dispatch('checkDataA',checkData)

        },
        openAddbulk(row){
            console.log(row);
            this.$store.dispatch('changeDialogActions')
            let bulkState=this.$store.state.PreferentialData.bulkState;
            if(bulkState==='1'){
                this.$store.dispatch('changebulkTitleActions','编辑团购优惠')
            }
            if(bulkState==='2'){
                this.$store.dispatch('changebulkTitleActions','编辑限时抢购')
            }
            if(bulkState==='3'){
                this.$store.dispatch('changebulkTitleActions','编辑购房补贴')
            }
            this.$store.dispatch('changebulkDataActions',row)
        },
        handleSizeChange(val){
            console.log(val);
            this.perPageNum=val;
            this.getTableData(this.nowPage, this.perPageNum)
            this.getTableData(this.nowPage, this.perPageNum)
        },
        handleCurrentChange(val){
            this.nowPage=val;
            this.getTableData(this.nowPage, this.perPageNum)
        },
        getTableData(nowPage,perPageNum){
            let data=function(a,b){
                this.nowPage=a;
                this.perPageNum=b
            }
            const data1=new data(nowPage,perPageNum)
            this.$store.dispatch('gettableDataActions',data1)
        }
    },
    created() {
         this.getTableData(1,5)
    },

}
</script>

<style>
.el-pagination { text-align: center; }

</style>